<?php
require_once("../class2.php");
require_once(HEADERF);
require_once("./cms/includes/require_all.php");
$database->cyr_chars();
$page_class = "PlayON"; //Key for non-users
ramka("open");
?>
<?php
echo "<a href='index.php' class='forumheader4' style='font-size:14px; margin-left:10px;'>НАЗАД</a>";
echo "<center class='forumheader4' style='margin-top:-20px; margin-left:-1px; padding-bottom:10px;'><h1 style='border-bottom:0px;'>Статистика на повторенията</h1></center>";
echo "<div class='forumheader3'></div>";
	
if(check_class($page_class)){
	if(isset($_POST['submit'])){
		echo "<div class='forumheader3'>";
		$num = $_POST['count'];
		$game = $_POST['game'];
		$br = 1;
		$q = mysql_query("select * from admin_panel where game_percent <> 100");
		while($a = mysql_fetch_array($q)){
			if($game == $br){
				$count = 1;
				$pref = $a['game_prefix'];
				$qq = mysql_query("SELECT english, COUNT(*) AS cat_num FROM ".$pref."_text GROUP BY english ORDER BY cat_num DESC limit 0, $num");
				echo "<table width='500'><tr class='forumheader'><td>№</td><td>Текст</td><td>Вече преведени</td></tr>";
				while($aa = mysql_fetch_array($qq)){
					$eng = $aa['english'];
					$number = $aa['cat_num'];
					$qqq = mysql_query("select * from ".$pref."_text where english = binary '$eng'");
					$nn = 0;
					while($aaa = mysql_fetch_array($qqq)){
						if(preg_match("/[а-яА-Я]{2,}/u", $aaa['content']) or $aaa['content'] == "" or preg_match("/(_IGcoLLen)/", $aaa['text_id'])){
							$nn++;
						}
					}
					echo "<tr class='forumheader3'><td class='textWHITE'>$count</td><td>$eng</td><td class='textWHITE'>$nn/$number</td></tr>";
					$count++;
				}
				echo "</table>";
				break;
			}
			$br++;
		}
	echo "</div>";
	}
	else{
		echo '<div class="forumheader">';
		echo '<form action="" method="post">';
		echo 'Покажи ми първите <input type="text" name="count" size="1" class="tbox"> реда от игра номер <input type="text" name="game" size="1" class="tbox"> ';
		echo "<input type='submit' value='Покажи' name='submit' class='tbox' style='cursor:pointer;'>";
		echo '</form></div><div class="forumheader3"></div>';
		echo '<div class="forumheader3">';
		$q = mysql_query("select * from admin_panel where game_percent <> 100");
		$br = 1;
		while($a = mysql_fetch_array($q)){
			echo "<div style='margin-top:10px;'><span class='forumheader3'>$br</span> <span class='forumheader textGREY'>$a[game_name]</span></div>";
			$br++;
		}
		echo '<br></div>';
	}
	echo '<div class="forumheader3"></div>';
}
else{
	echo "<center><font color=red>Само регистрирани потребители могат да се включат в превода</font></center>";
}

ramka("close");
require_once(FOOTERF);
?>